﻿using Refit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;

namespace refit_sample.Controllers
{
    /// <summary>
    /// github: https://github.com/reactiveui/refit
    /// </summary>
    public class UserController : ApiController
    {
        [HttpGet]
        public async Task<Object> Index()
        {
            var setting = new RefitSettings();
           

            var api = RestService.For<IWeatherAPI>("http://t.weather.sojson.com");


            var winfo = await api.GetWeather("101030100");

            return winfo;
        }
    }
    public interface IWeatherAPI
    {
        [Get("/api/weather/city/{code}")]
        Task<IWeatherInfo> GetWeather(string code);
    }

    public class IWeatherInfo
    {
        public string Time { get; set; }
        public string Date { get; set; }
    }

}
